<?
class PNUserFavouriteArray extends PNObjectExArray {
  function PNUserFavouriteArray($init=null, $where='')
  {
    $this->PNObject();

    $this->_objType       = 'innoforum_favourite';
    $this->_objField      = 'id';
    $this->_objPath       = 'form';
    $this->_objGroup      = 'fav_topic_id';

    $this->_objJoin[]     = array ( 'join_table'  =>  'innoforum_topics',
                            'join_field'          =>  array('id',
                                                            'title',
                                                            'ref_id',
                                                            'has_image',
                                                            'firstimage',
                                                            'firsthumbimage',
                                                            'count_view',
                                                            'count_post',
                                                            'price',
                                                            'update_icon',
                                                            'type_id',
                                                            'category_id',
                                                            'subcategory_id',
                                                            'onsale',
                                                            'status',
                                                            'province',
                                                            'price_detail',
                                                            'name'),
                            'object_field_name'   =>  array('tpc_id',
                                                            'title',
                                                            'ref_id',
                                                            'has_image',
                                                            'firstimage',
                                                            'firsthumbimage',
                                                            'count_view',
                                                            'count_post',
                                                            'price',
                                                            'update_icon',
                                                            'type_id',
                                                            'category_id',
                                                            'subcategory_id',
                                                            'onsale',
                                                            'status',
                                                            'province',
                                                            'price_detail',
                                                            'name'),
                            'compare_field_table' =>  'topic_id',
                            'compare_field_join'  =>  'id');

    $this->_init($init, $where);

  }

  function genFilter(){
    $user  = InnoUtil::getUserInfo();
    
    if($user){
      $where = "fav_uid = ".$user['uid'];
    }else {
      $where = "fav_uid = -1";
    }
    return $where;
  }

  function genSort(){
      return 'ORDER BY fav_id DESC';
  }
}

